<?php
/**
 * 统计我的js代码的行数
 */
function statCode($dir){
	global $total,$ignoreFiles;
	$list = scandir($dir);
	foreach($list as $k=>$v){
		if($v == '.' || $v =='..') continue;
		if(in_array($v, $ignoreFiles)) continue;
		$ext = strtolower(substr($v, -3));
		if(is_dir($dir.'/'.$v)){
			statCode($dir.'/'.$v);
		}
		else if($ext == '.js'){
			$a = file($dir.'/'.$v);
			$total += count($a);
		}
	}
}

$baseDir = '../../../oyster';
$total = 0;//完成数
$ignoreFiles = array('node_modules', 'lib');
statCode($baseDir);
$target = 50000; //目标数
$percent = 100 * $total / $target;
?>
<!DOCTYPE html>
<html>
    <head>
        <title>完成度</title>
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
    </head>
    <body>
        代码行数：<?php echo $total;?> 行<br>
        目标行数：<?php echo $target;?> 行<br>
        完成度：<?php echo $percent;?> %<br>
    </body>
</html>